<?

	include("inc/config.inc.php");
    
	    include("inc/header.inc.php");

	// Check we are HR!
	if ($_SESSION[role] != "HR")
		die ("Error 51 - User error - Please contact support.");



        echo "<h2><span class='textColorChange'>$config[systemtitle]</span></h2><br/>\n\n";

        echo "<a href='main.php' style='color:black;font-size:10pt'><< Back</a><br/>";

	echo "<div style='background:#504E52' class='normalText' width='400'>\n";
	echo "<b>Add New User</b><br/><br/>\n";

	echo "<script>
	function validateForm()
	{
		if (document.forms['form']['firstname'].value == '' || document.forms['form']['lastname'].value == '' || document.forms['form']['email'].value == '' || document.forms['form']['user'].value == '' ||document.forms['form']['manager'].value == '' || document.forms['form']['entitlement'].value == '')
		{
			alert('Please fill in all fields!');
			return false;
		}
	}
	</script>
    ";

	echo "<form name='form' action='usernewdo.php' method='POST' onsubmit='return validateForm();'>\n";
	echo "<table BORDERCOLORLIGHT='#807E7C' BORDERCOLORDARK='#383634' width='400' border='1'><tr><td>First Name:</td><td><input type='text' name='firstname'></td></tr>\n";
	echo "<tr><td>Last Name:</td><td> <input type='text' name='lastname'></td></tr>\n";
	echo "<tr><td>Username:</td><td> <input type='text' name='user'></td></tr>\n";
	echo "<tr><td>Email:</td><td> <input type='text' name='email'></td></tr>\n";

	echo "<tr><td>Role:</td><td><select name='role'><option selected value='Employee'>Employee</option><option value='Manager'>Manager</option><option value='HR'>HR</option></select></td></tr>\n";

	echo "<tr><td>Manager:</td><td><select name='manager'>\n";
	
	$result = mysqli_query($conn, "SELECT * FROM users WHERE (role='Manager' OR role='HR') AND deleted=0 ORDER BY user");
		while ($mgr = mysqli_fetch_array($result))
			echo "<option value='$mgr[user]'>$mgr[user]</option>\n";
	
	echo "</select></td></tr>\n";

	echo "<tr><td>Entitlement:</td><td> <input type='text' name='entitlement'></td></tr></table>\n";

	echo "<br/><input type='submit' value=' Add User '><br>\n";

	echo "</div>\n";
	echo "\n<br/>\n\n";

	include("inc/footer.inc.php");
    
?>
    
